#ifndef _GAME_MAP_H_
#define _GAME_MAP_H_

#include "SDL2/SDL.h"

/* the map
 * describes a horizontal array of "platforms"
 * each platform has a number, showing its height
 * currently all platforms have the same width
 */
struct game_map {

	// background
	SDL_Texture *bg_tex;

	// platforms's texture and rect
	SDL_Texture *tex_top;
	SDL_Texture *tex_mid;
	SDL_Rect rect;

	// array with platforms and their width
	float grid[10];
	float grid_width;
	float grid_height;

	/* actual height of all platforms, 
	 * platforms follow that height constantly
	 */
	float grid_actual[10];

	// water
	SDL_Rect water_rect;
	int water_delay;
	int water_actual;
	float water_speed;

	int offset_x;
	int offset_y;
};

/* init update and draw
 */
void game_map_init(struct game_map*);
void game_map_update(struct game_map*);
void game_map_draw(struct game_map*);
void game_map_draw_front(struct game_map *m);

/* returns the height of the platform with a given index
 * returns a value out of bounds when index is -1 or >= array size
 */
int game_map_platform_y(struct game_map*, int index);
int game_map_platform_x(struct game_map*, int index);
int game_map_platform_width(struct game_map *);

// returns number of platforms
int game_map_platform_number(struct game_map *);

/* returns the index of the platform on given location
 * returns -1 when location is on the left of the leftmost platform
 * or array's max value if location is on the right of it
 */
int game_map_platform_id(struct game_map*, int loc);

// offsets the map
void game_map_offset(struct game_map *, int x, int y);

// control the platform's position
void game_map_platform_rise(struct game_map *, int index, int amount);

// get water position
int game_map_water_y(struct game_map *);

#endif
